package org.ytor.core.sysapi.dict.repository;

import org.ytor.core.sqlflow.BaseRepository;
import org.ytor.core.sqlflow.builder.select.SelectBuilder;
import org.ytor.core.sqlflow.builder.select.WhereStage;
import org.ytor.core.sysapi.dict.model.SysDict;

import java.util.List;
import java.util.Map;

/**
 * created by   on 2025年4月13日 16:01:41
 * <br/>
 * SysRole表Mapper
 * <br/>
 */
public class SysDictRepository extends BaseRepository<SysDict> {

    /**
     * 翻译表级字典
     */
    public List<Map<String, Object>> translateByTable(String table, String column, List<?> value, String[] queryColumnArr) {
        SelectBuilder selectBuilder = new SelectBuilder();
        for (String col : queryColumnArr) {
            selectBuilder.selectRaw(col);
        }
        WhereStage select = selectBuilder.from(table, "t")
                .where(w -> w.eq(value.isEmpty(), column, "-1").in(!value.isEmpty(), column, value));

        return select.listMap();
    }
}